#ifndef __CONN_H__
#define __CONN_H__
#include <iostream>
#include <string>
#include <functional>
#include "Common.hpp"
class Reactor;

using handler_t =std::function<std::string(std::string&)>;
class Connection
{
public:
    Connection(){}
    virtual ~Connection(){}

    void SetEvent(uint32_t events)
    {
        _events=events;
    }
    uint32_t GetEvents()
    {
        return _events;
    }

    virtual void Recv()=0;
    virtual void Send()=0;
    virtual void Excpeter()=0;
    

    void SetOwner(Reactor* owner)
    {
        _owner=owner;
    }
    Reactor* GetOwner()
    {
        return _owner;
    }
    virtual int getFd()=0;
    void RegisterHanlder(handler_t handler)
    {
        _handler=handler;
    }
private:
    //回指指针
    Reactor* _owner;
    //关心的事件
    uint32_t _events;
public:
    handler_t _handler;
};
#endif